import { Message, MessageBox } from 'element-ui'
import { current } from '@/api/current.js'
import router from '@/router'

export default {
    namespaced: true,
    actions: {
        /**
         * @description 检测有无待交接班
         * @param {Object} param context 酒店id
         */
        checkHandover({ commit, dispatch }, { hotel_id } = {}) {
            /**
             * @description 检测有无待交接班
             */
            let data = {
                hotel_id,
            }
            current('http://110.40.192.219/api/supplier/hotel-pms-handover-check', data, 'GET').then(res => {
                console.log(res, '结果有无待交接班');
                let { code, data } = res.data
                if (data.id != 0) {//data.id= 0时代表没有待接班
                    MessageBox.confirm('尚有待接班记录,去通过“统计-交接班报表查看”', '', {
                        confirmButtonText: '去接班',
                        // cancelButtonText: '拒绝',
                        type: 'warning',
                        closeOnClickModal: false,
                        showClose: false,
                        showCancelButton: false,
                    }).then(() => {
                        router.push({
                            name: 'ShiftWorkTable',
                            params: {
                                id: data.id
                            }
                        })
                    })
                }
            })

        }
    }
}
